// sets system parameters on powerup and restart.

/*
 Required includes:	avr/wdt.h
					avr/interrupt.h
					stdint.h
 */

/*
 Copyright 2010 Anthony Oko, Koby Hitchen, Mara Cairo, Shaochen Xu, Tyler Lucas
 
 This file is part of the trajctrl program.
 
 trajctrl is licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
 http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

#include "system_init.h"

void system_init()
{	
	// turn off watchdog
	wdoff();

	// turn off interrupts
	cli();

	// fuse settings
	
	// generate lookup tables
	
	// set pins as i/p or o/p
	DDRA |= 0b00000000;	// ADC
	DDRB |= 0b11111111;	// DAC
	DDRC |= 0b11000011; // JTAG, analog MUX selects, encoder select
	DDRD |= 0b10111100; // encoder select, misc. I/O, laser ctrl, parallel plate ctrl, LED

	// POST
	ledmsg("--");
}

void wdoff()
{
	MCUSR = 0;
	wdt_disable();
}
